import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'fisrtPage.dart';
import 'Second.dart';
import 'fourDart.dart';
class ShowManin extends StatefulWidget {

  _ShowManinState createState() {
    return _ShowManinState();
  }
}

class _ShowManinState extends State<ShowManin> {
  @override
  final _bottomNavigationColor = Colors.blue;
  int _currentIndex = 0;
  var appBarTitles = ['首页', '发现', '我的'];
  PageController _controller;
 var tabImages;

 var _pageList;

  Image getTabImage(path) {
    return new Image.asset(path, width: 24.0, height: 24.0);
  }
  Image getTabIcon(int curIndex) {
    if (curIndex == _currentIndex) {
      return tabImages[curIndex][1];
    }
    return tabImages[curIndex][0];
  }

  Text getTabTitle(int curIndex) {
    if (curIndex == _currentIndex) {
      return new Text(appBarTitles[curIndex],
          style: new TextStyle(fontSize: 14.0, color: const Color(0xff1296db)));
    } else {
      return new Text(appBarTitles[curIndex],
          style: new TextStyle(fontSize: 14.0, color: const Color(0xff515151)));
    }
  }

  void initData() {
    /*
     * 初始化选中和未选中的icon
     */
    tabImages = [
      [getTabImage('sampledata/1.jpg'), getTabImage('sampledata/1.jpg')],
      [getTabImage('sampledata/1.jpg'), getTabImage('sampledata/1.jpg')],
      [getTabImage('sampledata/1.jpg'), getTabImage('sampledata/1.jpg')]//在元目录下创建文件在并创建1。0X/2.0X放入图片目录
    ];
    /*
     * 三个子界面
     */
    _pageList = [
      new HomePage(),
      new AuthenticationId(),
      new MinePage(),
    ];

  }

  Widget build(BuildContext context) {
    // TODO: implement build
    initData();
    return Scaffold(
        body: Container(
          child: Column(
            children: <Widget>[
              Expanded(
               child:Container(
                child:_pageList[_currentIndex],
              ),
              ),
              Expanded(
              child:Stack(
                children: [
                  Positioned(

                    bottom: 0,

                    left: 0,

                    right: 0,

                    height: 64,

                    child: BottomNavigationBar(
              items: <BottomNavigationBarItem>[
              new BottomNavigationBarItem(
                  icon:  Icon(//getTabIcon[0]
                      Icons.email,
                      color: _bottomNavigationColor,
                    ), title: getTabTitle(0)),
              new BottomNavigationBarItem(
                  icon: Icon(
                    Icons.pages,
                    color: _bottomNavigationColor,
                  ), title: getTabTitle(1)),
              new BottomNavigationBarItem(
                  icon:Icon(
                    Icons.airplay,
                    color: _bottomNavigationColor,
                  ), title: getTabTitle(2)),
            ],
              type: BottomNavigationBarType.fixed,
              //默认选中首页
              currentIndex: _currentIndex,
              iconSize: 24.0,
              //点击事件
              onTap: (index) {
                setState(() {
                  _currentIndex = index;


                });
              },

                  )

                ),

                    ],


              ),


),




            ],
          ),
        ));
  }
}
